content
Class Vehicle

java.lang.Object
  extended by content.Vehicle

public class Vehicle
extends java.lang.Object

Vehicle class is a structure of basic attributes for any vehicle. This class uses Color class to implement any possible vehicle colour.

Since:
29.03.09
Version:
2.0
Author:
Dolev&Morad
See Also:
Color

Constructor Summary
Vehicle(int licensePlate, int year, EngineType engineType, Chassis chassis, java.lang.String model, java.awt.Color colour, int numDoors)
          This method is a constructor for vehicle class.
 
Method Summary
 boolean equals(java.lang.Object obj)
          Compares two Vehicles for equality by License Plate number
 Chassis getChassis()
          This method returns vehicle's chassis name from possible options of the enum class.
 java.lang.String getColour()
          This method checks if colour is not null.
 EngineType getEngineType()
          This method contains vehicle's engine type from a possible options of the enum class.
 int getLicensePlate()
          This method
 java.lang.String getModel()
          This method
 int getNumDoors()
          This method
 int getYear()
          This method
 int hashCode()
          The method creates hash indexes for hashTable by activating hashCode on primary fields.
 void setChassis(Chassis chassis)
          This method allows to update chassis for this vehicle.
 void setColour(java.awt.Color colour)
          The method updates the colour of the vehicle, after the input colour is checked and it is one of the legal colours.
 void setEngineType(EngineType engineType)
          This method allows to update engineType for this vehicle.
 java.lang.String toString()
          The method @return a string representation of a Vehicle.
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Vehicle

public Vehicle(int licensePlate,
               int year,
               EngineType engineType,
               Chassis chassis,
               java.lang.String model,
               java.awt.Color colour,
               int numDoors)
This method is a constructor for vehicle class.

Parameters:
year -
manufacturer -
model -
colour -
numDoors -
Method Detail

getYear

public int getYear()
This method

Returns:
the year attribute.

getColour

public java.lang.String getColour()
This method checks if colour is not null.

Returns:
the colour attribute as a String. If null the Unknown colour String returned.

setColour

public void setColour(java.awt.Color colour)
The method updates the colour of the vehicle, after the input colour is checked and it is one of the legal colours. The vehicle can be coloured in only 4 colours, BLACK, BLUE, GREEN or WHITE . Any other colour is illegal and set as null.

Parameters:
colour -

getModel

public java.lang.String getModel()
This method

Returns:
the model attribute.

getNumDoors

public int getNumDoors()
This method

Returns:
the number of doors attribute.

getLicensePlate

public int getLicensePlate()
This method

Returns:
the license plate attribute.

equals

public boolean equals(java.lang.Object obj)
Compares two Vehicles for equality by License Plate number

Overrides:
equals in class java.lang.Object

hashCode

public int hashCode()
The method creates hash indexes for hashTable by activating hashCode on primary fields.

Overrides:
hashCode in class java.lang.Object
See Also:
getLicensePlate()

toString

public java.lang.String toString()
The method @return a string representation of a Vehicle.

Overrides:
toString in class java.lang.Object

getChassis

public Chassis getChassis()
This method returns vehicle's chassis name from possible options of the enum class.

Returns:
the chassis
See Also:
Chasis#java

setChassis

public void setChassis(Chassis chassis)
This method allows to update chassis for this vehicle.

Parameters:
chassis -

getEngineType

public EngineType getEngineType()
This method contains vehicle's engine type from a possible options of the enum class.

Returns:
the engineType of the vehicle.
See Also:
engineType#java

setEngineType

public void setEngineType(EngineType engineType)
This method allows to update engineType for this vehicle.

Parameters:
engineType -